package main

import (
	"fmt"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	ch := make(chan int)

	wg.Add(1)
	go func() {
		for i := 0; i < 100; i++ {
			ch <- i
		}
		close(ch)
		wg.Done()
	}()

	for i := 0; i < 3; i++ {
		wg.Add(1)
		go func(id int) {
			for v := range ch {
				fmt.Printf("id(%d): %d\n", id, v)
			}
			wg.Done()
		}(i)
	}

	wg.Wait()
}
